package com.example.demo.domain.exam;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.annotation.Display;
import com.example.demo.enums.LanguageType;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;

/**
 * 提交记录
 */
@Data
@RequiredArgsConstructor
@TableName(value = "exam_submit_log")
public class ExamSubmitLog {

    // 评测机正常
    public static final int EXAM_SUBMIT_LOG_NORMAL_STATUS = 1;

    // 评测机出错
    public static final int EXAM_SUBMIT_LOG_ERROR_STATUS = 2;

    @Display("提交记录标识")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @Display("考试标识")
    @TableField(value = "exam_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long examId;

    @Display("考试名称")
    @TableField(value = "exam_name")
    private String examName;

    @Display("试卷标识")
    @TableField(value = "paper_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long paperId;

    @Display("试卷标识")
    @TableField(value = "question_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long questionId;

    @Display("班级标识")
    @TableField(value = "class_id")
    private Long classId;

    @Display("提交时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "submit_time")
    private Timestamp submitTime;

    @Display("用户标识")
    @TableField(value = "user_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    @Display("用户名称")
    @TableField(value = "username")
    private String username;

    @Display("考试开始时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(value = "start_time")
    private Timestamp startTime;

    @Display("题目得分")
    @TableField("score")
    private Double score;

    @Display("提交内容")
    @TableField("content")
    private String content;

    @Display("语言类型")
    @TableField("language_id")
    private Integer languageId;

    @Display("语言选择")
    @TableField("type")
    private LanguageType type;

    @Display("提交评测标识")
    @TableField("submission_id")
    private Long submissionId;

    @Display("执行用时——ms")
    @TableField("execute_time")
    private Integer executeTime;

    @Display("内存消耗——MB")
    @TableField("user_memory")
    private Integer userMemory;

    @Display("本次评测机状态")
    @TableField("status")
    private Integer status;

    @Display("评测结果")
    @TableField("judge_result")
    private String judgeResult;

    @Display("评测日志")
    @TableField("judge_log")
    private String judgeLog;

}
